﻿using SmartPatientCentre.Models;
using SmartPatientCentre.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartPatientCentre.Repositories
{
    public class PatientRepository
    {
        public List<Patient> PatientList { get; private set;}
        public ResultsViewModel RVM { get; private set; }
        public Patient Patient
        {
            get
            {
                return PatientList.First();
            }
        }
        private List<UniqueResult> rl;
        public List<UniqueResult> ResultList
        {
            get
            {
                //return RVM.Sodium;
                return rl;
            }
        }

        public PatientRepository()
        {
            // Create a list of Patients
            PatientList = new List<Patient>();

            Patient jb = new Patient()
            {
                Id = 1,
                FirstName = "John",
                LastName = "Burn",
                DateOfBirth = new DateTime(1969, 10, 21),
                Ward = "Special Care",
                Room = "A",
                Bed = 6,
                Gender = "Male"
            };

            Patient pk = new Patient()
            {
                FirstName = "Peter",
                LastName = "Kelly",
                DateOfBirth = new DateTime(1950, 2, 14),
                Ward = "Medical",
                Room = "C",
                Bed = 2,
                Gender = "Male"
            };

            Patient bs = new Patient()
            {
                FirstName = "Britney",
                LastName = "Spears",
                DateOfBirth = new DateTime(1981, 12, 2),
                Ward = "Psychiatry",
                Room = "Z",
                Bed = 3,
                Gender = "Female"
            };

            // Create a list of Results
            rl = new List<UniqueResult>();

            Result Na1 = new Result()
            {
                Sodium = 130,
                Potassium = 4,
                Urea = 7.8M,
                Creatinine = 41,
                DateTime = new DateTime(2014, 2, 1)
            };
            Result Na2 = new Result()
            {
                Sodium = 135,
                Potassium = 2.9M,
                Urea = 8.2M,
                Creatinine = 63,
                DateTime = new DateTime(2014, 2, 2)
            };
            Result Na3 = new Result()
            {
                Sodium = 140,
                Potassium = 5,
                Urea = 5.2M,
                Creatinine = 77,
                DateTime = new DateTime(2014, 2, 3)
            };
            Result Na4 = new Result()
            {
                Sodium = 145,
                Potassium = 4.5M,
                Urea = 4.7M,
                Creatinine = 82,
                DateTime = new DateTime(2014, 2, 4)
            };
            Result Na5 = new Result()
            {
                Sodium = 150,
                Potassium = 3.2M,
                Urea = 3.3M,
                Creatinine = 99,
                DateTime = new DateTime(2014, 2, 5)
            };
            Result Na6 = new Result()
            {
                Sodium = 155,
                Potassium = 5.3M,
                Urea = 1.7M,
                Creatinine = 121,
                DateTime = new DateTime(2014, 2, 6)
            };

            // Create UniqueResults
            UniqueResult na1 = new SodiumResult(Na1);
            UniqueResult na2 = new SodiumResult(Na2);
            UniqueResult na3 = new SodiumResult(Na3);
            UniqueResult na4 = new SodiumResult(Na4);
            UniqueResult na5 = new SodiumResult(Na5);
            UniqueResult na6 = new SodiumResult(Na6);


            rl.Add(na1);
            rl.Add(na2);
            rl.Add(na3);
            rl.Add(na4);
            rl.Add(na5);
            rl.Add(na6);

            // Add the list of Results to a Patient
            //jb.Results = rl;

            PatientList.Add(jb);
            PatientList.Add(pk);
            PatientList.Add(bs);

            // Create a ResultsViewModel
            //RVM = new ResultsViewModel(jb);
        }
    }
}
